a11y: Add child state change to GtkATContext
authorEmmanuele Bassi <ebassi@gnome.org>
Thu, 15 Oct 2020 13:49:14 +0000 (14:49 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Wed, 21 Oct 2020 13:04:49 +0000 (14:04 +0100)
And the required private API in GtkAccessible to notify AT contexts of
changes in the children list.

gtk/gtkaccessible.c
gtk/gtkaccessibleprivate.h
gtk/gtkatcontext.c
gtk/gtkatcontextprivate.h

index bef2ced14eb2de9c0f832a982603cf6c00f40016..32916de27b422ccd00eee5e86663b5918a322efd 100644 (file)
@@ -751,3 +751,27 @@ gtk_accessible_should_present (GtkAccessible *self)
 
   return TRUE;
 }
+
+void
+gtk_accessible_update_children (GtkAccessible           *self,
+                                GtkAccessible           *child,
+                                GtkAccessibleChildState  state)
+{
+  GtkATContext *context;
+
+  if (GTK_IS_WIDGET (self) &&
+      gtk_widget_get_root (GTK_WIDGET (self)) == NULL)
+    return;
+
+  context = gtk_accessible_get_at_context (self);
+
+  /* propagate changes up from ignored widgets */
+  if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE)
+    context = gtk_accessible_get_at_context (GTK_ACCESSIBLE (gtk_widget_get_parent (GTK_WIDGET (self))));
+
+  if (context == NULL)
+    return;
+
+  gtk_at_context_child_changed (context, state, child);
+  gtk_at_context_update (context);
+}
index 966efc3abba001289ca6fa4090b79a71ea9e70e6..873af7009ae10891daa8f2c5dbeb6a0cbe01de1c 100644 (file)
@@ -49,4 +49,8 @@ gboolean        gtk_accessible_get_platform_state (GtkAccessible              *s
 
 void            gtk_accessible_bounds_changed   (GtkAccessible *self);
 
+void            gtk_accessible_update_children  (GtkAccessible           *self,
+                                                 GtkAccessible           *child,
+                                                 GtkAccessibleChildState  state);
+
 G_END_DECLS
index dd771bc10c38cbdbde9279ac2dc58eaf8e84d998..6e0c54693f1c3a0bae508ae7c8bb3b21e24eeac2 100644 (file)
@@ -155,6 +155,13 @@ gtk_at_context_real_bounds_change (GtkATContext *self)
 {
 }
 
+static void
+gtk_at_context_real_child_change (GtkATContext             *self,
+                                  GtkAccessibleChildChange  change,
+                                  GtkAccessible            *child)
+{
+}
+
 static void
 gtk_at_context_class_init (GtkATContextClass *klass)
 {
@@ -167,6 +174,7 @@ gtk_at_context_class_init (GtkATContextClass *klass)
   klass->state_change = gtk_at_context_real_state_change;
   klass->platform_change = gtk_at_context_real_platform_change;
   klass->bounds_change = gtk_at_context_real_bounds_change;
+  klass->child_change = gtk_at_context_real_child_change;
 
   /**
    * GtkATContext:accessible-role:
@@ -979,3 +987,11 @@ gtk_at_context_bounds_changed (GtkATContext *self)
 {
   GTK_AT_CONTEXT_GET_CLASS (self)->bounds_change (self);
 }
+
+void
+gtk_at_context_child_changed (GtkATContext             *self,
+                              GtkAccessibleChildChange  change,
+                              GtkAccessible            *child)
+{
+  GTK_AT_CONTEXT_GET_CLASS (self)->child_change (self, change, child);
+}
index edc7fa3c944d5ab4b5780a5c047fd55c3b2fbbff..85d897be90e193cfa39c1ce81da10b9fe89b8316 100644 (file)
@@ -90,6 +90,16 @@ typedef enum {
   GTK_ACCESSIBLE_PLATFORM_CHANGE_FOCUSED   = 1 << GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED,
 } GtkAccessiblePlatformChange;
 
+typedef enum {
+  GTK_ACCESSIBLE_CHILD_STATE_ADDED,
+  GTK_ACCESSIBLE_CHILD_STATE_REMOVED
+} GtkAccessibleChildState;
+
+typedef enum {
+  GTK_ACCESSIBLE_CHILD_CHANGE_ADDED   = 1 << GTK_ACCESSIBLE_CHILD_STATE_ADDED,
+  GTK_ACCESSIBLE_CHILD_CHANGE_REMOVED = 1 << GTK_ACCESSIBLE_CHILD_STATE_REMOVED
+} GtkAccessibleChildChange;
+
 struct _GtkATContext
 {
   GObject parent_instance;
@@ -124,6 +134,10 @@ struct _GtkATContextClass
                             GtkAccessiblePlatformChange  changed_platform);
 
   void (* bounds_change) (GtkATContext                *self);
+
+  void (* child_change) (GtkATContext             *self,
+                         GtkAccessibleChildChange  changed_child,
+                         GtkAccessible            *child);
 };
 
 GdkDisplay *            gtk_at_context_get_display              (GtkATContext          *self);
@@ -158,6 +172,9 @@ char *                  gtk_at_context_get_description          (GtkATContext
 void                    gtk_at_context_platform_changed         (GtkATContext                *self,
                                                                  GtkAccessiblePlatformChange  change);
 void                    gtk_at_context_bounds_changed           (GtkATContext                *self);
+void                    gtk_at_context_child_changed            (GtkATContext                *self,
+                                                                 GtkAccessibleChildChange     change,
+                                                                 GtkAccessible               *child);
 
 const char *    gtk_accessible_property_get_attribute_name      (GtkAccessibleProperty property);
 const char *    gtk_accessible_relation_get_attribute_name      (GtkAccessibleRelation relation);